package com.business.api.official.toursism.websiteshop.manager.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.business.api.official.toursism.websiteshop.manager.WebsiteShopApiManager;
import com.business.api.official.toursism.websiteshop.mapper.WebsiteShopApiMapper;
import com.business.api.official.toursism.websiteshop.vo.WebsiteShopApiBriefListVO;
import com.business.api.official.toursism.websiteshop.vo.WebsiteShopApiBriefVO;
import com.business.api.official.toursism.websiteshop.vo.WebsiteShopApiDetailListVO;
import com.business.api.official.toursism.websiteshop.vo.WebsiteShopApiDetailVO;
import com.business.api.official.toursism.websiteshop.vo.data.WebsiteShopApiBriefData;
import com.business.api.official.toursism.websiteshop.vo.data.WebsiteShopApiDetailData;
import com.business.system.official.toursism.websiteshop.entity.WebsiteShop;
import com.business.system.official.toursism.websiteshop.manager.WebsiteShopManager;
import com.seed.core.exception.ManagerException;
import com.seed.core.pojo.manager.impl.SeedApiManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 购物车
 * @author CodeGenerator
 * @date   2025-01-25
 * @version V1.0
 */
@Slf4j
@Service("websiteShopApiManager")
@Transactional(rollbackFor = ManagerException.class)
public class WebsiteShopApiManagerImpl extends SeedApiManagerImpl<WebsiteShopApiMapper, WebsiteShop> implements WebsiteShopApiManager {
    @Autowired
    private WebsiteShopManager systemManager;

    /**
     * 根据id获取详情VO data
     *
     * @param websiteShopId 对象id
     * @return 详情VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailData convertApiDetailData(String websiteShopId) throws ManagerException {
        WebsiteShop websiteShop = this.getById(websiteShopId);
        return this.convertApiDetailData(websiteShop);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteShop model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailData convertApiDetailData(WebsiteShop websiteShop) throws ManagerException {
        WebsiteShopApiDetailData websiteShopApiDetailData = new WebsiteShopApiDetailData();
        try {
            BeanUtils.copyProperties(websiteShop, websiteShopApiDetailData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteShop);
        }
        return websiteShopApiDetailData;
    }

    /**
     * 根据id获取详情VO
     *
     * @param websiteShopId 对象id
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailVO getApiDetailVO(String websiteShopId) throws ManagerException {
        WebsiteShopApiDetailData websiteShopApiDetailData = this.convertApiDetailData(websiteShopId);
        return new WebsiteShopApiDetailVO(websiteShopApiDetailData);
    }

    /**
     * 根据对象获取详情VO
     *
     * @param websiteShop 对象
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailVO getApiDetailVO(WebsiteShop websiteShop) throws ManagerException {
        WebsiteShopApiDetailData websiteShopApiDetailData = this.convertApiDetailData(websiteShop);
        return new WebsiteShopApiDetailVO(websiteShopApiDetailData);
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteShopApiDetailData> getConvertApiDetailListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteShop> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteShop::getId, ids);
        List<WebsiteShop> websiteShopList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteShopList);
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteShopApiDetailData> listConvertApiDetailData(Wrapper<WebsiteShop> queryWrapper) throws ManagerException {
        List<WebsiteShop> websiteShopList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteShopList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteShopList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteShopApiDetailData> listConvertApiDetailData(List<WebsiteShop> websiteShopList) throws ManagerException {
        List<WebsiteShopApiDetailData> websiteShopApiDetailDataList = new ArrayList<>();
        for (WebsiteShop websiteShop : websiteShopList) {
            websiteShopApiDetailDataList.add(this.convertApiDetailData(websiteShop));
        }
        return websiteShopApiDetailDataList;
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailListVO getApiDetailListVOByIds(List<String> ids) throws ManagerException {
        return new WebsiteShopApiDetailListVO(this.getConvertApiDetailListVOByIds(ids));
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailListVO getApiDetailListVO(Wrapper<WebsiteShop> queryWrapper) throws ManagerException {
        return new WebsiteShopApiDetailListVO(this.listConvertApiDetailData(queryWrapper));
    }

    /**
     * 根据对象list获取详情VO data list
     *
     * @param websiteShopList 对象list
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiDetailListVO getApiDetailListVO(List<WebsiteShop> websiteShopList) throws ManagerException {
        return new WebsiteShopApiDetailListVO(this.listConvertApiDetailData(websiteShopList));
    }

    /**
     * 根据id获取简略VO data
     *
     * @param websiteShopId 对象id
     * @return 简略VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefData convertApiBriefData(String websiteShopId) throws ManagerException {
        WebsiteShop websiteShop = this.getById(websiteShopId);
        return this.convertApiBriefData(websiteShop);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteShop model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefData convertApiBriefData(WebsiteShop websiteShop) throws ManagerException {
        WebsiteShopApiBriefData websiteShopApiBriefData = new WebsiteShopApiBriefData();
        try {
            BeanUtils.copyProperties(websiteShop, websiteShopApiBriefData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteShop);
        }
        return websiteShopApiBriefData;
    }

    /**
     * 根据id获取简略VO
     *
     * @param websiteShopId 对象id
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefVO getApiBriefVO(String websiteShopId) throws ManagerException {
        WebsiteShopApiBriefData websiteShopApiBriefData = this.convertApiBriefData(websiteShopId);
        return new WebsiteShopApiBriefVO(websiteShopApiBriefData);
    }

    /**
     * 根据对象获取简略VO
     *
     * @param websiteShop 对象
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefVO getApiBriefVO(WebsiteShop websiteShop) throws ManagerException {
        WebsiteShopApiBriefData websiteShopApiBriefData = this.convertApiBriefData(websiteShop);
        return new WebsiteShopApiBriefVO(websiteShopApiBriefData);
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteShopApiBriefData> listConvertApiBriefDataByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteShop> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteShop::getId, ids);
        List<WebsiteShop> websiteShopList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteShopList);
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteShopApiBriefData> listConvertApiBriefData(Wrapper<WebsiteShop> queryWrapper) throws ManagerException {
        List<WebsiteShop> websiteShopList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteShopList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteShopList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteShopApiBriefData> listConvertApiBriefData(List<WebsiteShop> websiteShopList) throws ManagerException {
        List<WebsiteShopApiBriefData> websiteShopApiBriefDataList = new ArrayList<>();
        for (WebsiteShop websiteShop : websiteShopList) {
            websiteShopApiBriefDataList.add(this.convertApiBriefData(websiteShop));
        }
        return websiteShopApiBriefDataList;
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefListVO getApiBriefListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteShop> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteShop::getId, ids);
        List<WebsiteShop> websiteShopList = this.list(queryWrapper);
        return new WebsiteShopApiBriefListVO(this.listConvertApiBriefData(websiteShopList));
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefListVO getApiBriefListVO(Wrapper<WebsiteShop> queryWrapper) throws ManagerException {
        List<WebsiteShop> websiteShopList = this.list(queryWrapper);
        return new WebsiteShopApiBriefListVO(this.listConvertApiBriefData(websiteShopList));
    }

    /**
     * 根据对象list获取简略VO data list
     *
     * @param websiteShopList 对象list
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteShopApiBriefListVO getApiBriefListVO(List<WebsiteShop> websiteShopList) throws ManagerException {
        return new WebsiteShopApiBriefListVO(this.listConvertApiBriefData(websiteShopList));
    }
}